import org.example.BSTree;
import org.example.RedBlackTree;
import org.example.util.BTreeUtil;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        RedBlackTree<Float, String> tree = new RedBlackTree<>();
        tree.put(3f, "3");
        tree.put(2f, "2");
        tree.put(1f, "1");
        tree.put(4f, "4");
        tree.put(5f, "5");
        tree.put(6f, "6");
        tree.put(7f, "7");

        tree.put(3.5f, "3.5");

        BTreeUtil.printRBTree(tree.getRoot());
        System.out.println("root of tree is " + tree.getRoot().getKey());
        Scanner scanner = new Scanner(System.in);
        float in = scanner.nextFloat();
        while(in >= 0) {
            System.out.println("remove node of " + tree.remove(in));

            BTreeUtil.printRBTree(tree.getRoot());
            System.out.println("root of tree is " + tree.getRoot().getKey());
            in = scanner.nextFloat();
        }
        BTreeUtil.inorderTraversal(tree.getRoot());
        System.out.println("get(5) and get(10): " + tree.get(5f) + "," + tree.get(10f));
    }
}
